package com.UdpRecieve.service.impl;

import com.UdpRecieve.domain.BusinessLog;
import com.UdpRecieve.domain.system.SysOperLog;
import com.UdpRecieve.domain.system.SysUser;
import com.UdpRecieve.framework.utils.ServletUtils;
import com.UdpRecieve.mapper.BusinessLogMapper;
import com.UdpRecieve.mapper.OperaLogMapper;
import com.UdpRecieve.service.SysLogService;
import com.UdpRecieve.tool.Convert;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class SysLogServiceImpl implements SysLogService {


    @Autowired
    private BusinessLogMapper businessLogMapper;

    @Autowired
    private OperaLogMapper operaLogMapper;

    /**
     * 查询业务日志
     * @param businessLog
     * @return
     */
    @Override
    public List<BusinessLog> selectBusinessLogList(BusinessLog businessLog) {
        return businessLogMapper.selectBusinessLogList(businessLog);
    }

    /**
     * 通过id删除业务日志
     * @param ids
     * @return
     */
    @Override
    public int deleteBusinessLogByIds(String ids) {
        Integer[] userIds = Convert.toIntArray(ids);
        return businessLogMapper.deleteBusinessLogByIds(userIds);
    }

    /**
     * 查询操作日志
     * @param sysOperLog
     * @return
     */
    @Override
    public List<SysOperLog> selectOperateLogList(SysOperLog sysOperLog) {
        //获取当前登录的用户
        SysUser sysUser = ServletUtils.getOnlineUser();
        sysOperLog.setRoleId(sysUser.getSysRole().getRoleId());
        return operaLogMapper.selectOperateLogList(sysOperLog);
    }

    @Override
    public int deleteOperaLogByIds(String ids) {
        Integer[] idList = Convert.toIntArray(ids);
        return operaLogMapper.deleteOperaLogByIds(idList);
    }

    @Override
    public int insertOperaLog(SysOperLog sysOperLog) {
        return operaLogMapper.insertOperaLog(sysOperLog);
    }


}
